package com.egg.auth.feign.fallback;

import com.egg.auth.feign.AuthAccountFeignClient;
import com.egg.auth.model.response.web.UserAccountInfo;
import com.egg.common.core.enums.ResponseCode;
import com.egg.common.core.model.response.ResponseData;
import feign.hystrix.FallbackFactory;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * feignClient降级
 *
 * @author east
 */
@Slf4j
@Configuration
public class AuthAccountFeignClientFallback implements FallbackFactory<AuthAccountFeignClient> {


    @Override
    public AuthAccountFeignClient create(Throwable cause) {
        return new AuthAccountFeignClient() {

            @Override
            public ResponseData<UserAccountInfo> userAccountInfo(
                    @ApiParam(value = "用户ID", required = true) @RequestParam(value = "userId") Long userId
                    , @ApiParam(value = "账号类型", required = true) @RequestParam(value = "accountType") String accountType
            ) {
                ResponseData res = new ResponseData<>();
                res.setMsg(ResponseCode.FALLBACK_ERROR.getMessage());
                res.setCode(ResponseCode.FALLBACK_ERROR.getCode());
                return res;
            }

        };

    }


}
